import static Constants.GradeConstant.*;
import static Constants.FractionalConstant.*;
import static java.lang.Math.min;


/**
 * Version: 1.0
 */

/**
 * @Author: 唐文涛
 * @CreateTime: 2024-11-08
 * @Description: 计算分数
 * @Version: 1.0
 * 说明：通过if-else语句判断成绩等级并计算分数
 */

//TODO: 2024-11-08 14:00:00
// 可以试试泛型化简

public class ScoreCalculator {


    //判断分数等级并计算分数
    public static double conversion(double score) {
        System.out.println("score = " + score);
        score = Math.floor(score);
        System.out.println("score = " + score);
        if (score >= 100) {
            return score;
        } else if (score >= 95) {
            return 95;
        } else if (score >= 90) {
            return 90;
        } else if (score >= 85) {
            return 85;
        } else if (score >= 80) {
            return 80;
        } else if (score >= 60) {
            return (score % 2 == 0) ? score : score - 1; // 凑整为偶数
        } else if (score >= 10) {
            return (score / 10.0) * 10; // 向下取整到十
        } else {
            return 0; // 低于 10 分
        }
    }


    // 将 Double 改为泛型
    public static <T extends Number> double beforeRound(T gradeBase, T grades, T base) {
        // 转换为 double 类型并计算
        return Math.round(gradeBase.doubleValue() + grades.doubleValue() + base.doubleValue());
    }

    // 将 Double 改为泛型
    public static <T extends Number> double afterRound(T grades, T gradeBase, T base) {
        // 转换为 double 类型并计算
        return Math.round((grades.doubleValue() - gradeBase.doubleValue()) / base.doubleValue());
    }

    //计算体重指数BMI
    public static double calculateBMIScore(int height, int weight) {
        double BMI = weight / (Math.pow(height / 100.0, 2));
        if (BMI >= OBESE_BMI) {
            return OBESE;
        } else if (BMI >= OVERWEIGHT_BMI) {
            return OVERWEIGHT;
        } else if (BMI >= NORMAL_BMI) {
            return NORMAL;
        } else {
            return UNDERWEIGHT;
        }
    }

    // 计算一千米跑步成绩
    public static double calculateOneThousandMeterRunScore(Integer oneThousandMeterRun, boolean isOneTwo) {

        Integer full = isOneTwo ? FULL_BOY_ONE_THOUSAND_METER_RUN_12 : FULL_BOY_ONE_THOUSAND_METER_RUN_34;
        Integer excellent = isOneTwo ? ((oneThousandMeterRun > EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_90_12) ? EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_95_12 : EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_90_12) : EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_34;
        Integer good = isOneTwo ? ((oneThousandMeterRun > GOOD_BOY_ONE_THOUSAND_METER_RUN_80_12) ? GOOD_BOY_ONE_THOUSAND_METER_RUN_85_12 : GOOD_BOY_ONE_THOUSAND_METER_RUN_80_12) : ((oneThousandMeterRun > GOOD_BOY_ONE_THOUSAND_METER_RUN_80_34) ? GOOD_BOY_ONE_THOUSAND_METER_RUN_85_34 : GOOD_BOY_ONE_THOUSAND_METER_RUN_80_34);
        Integer pass = isOneTwo ? PASS_BOY_ONE_THOUSAND_METER_RUN_12 : PASS_BOY_ONE_THOUSAND_METER_RUN_34;
        Integer fail = isOneTwo ? FAIL_BOY_ONE_THOUSAND_METER_RUN_12 : FAIL_BOY_ONE_THOUSAND_METER_RUN_34;

        // 判断成绩等级并计算分数
        double score;
        if (oneThousandMeterRun <= full) {
            if (oneThousandMeterRun - full > 20) {
                score = FULL + min(((oneThousandMeterRun - full) - FIVE) / THREE, 10);
            } else {
                score = FULL + min((full - oneThousandMeterRun) / FOUR, 10);
            }
        } else if (oneThousandMeterRun <= excellent) {
            Double excelBase = isOneTwo ? ((oneThousandMeterRun > EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_90_12) ? EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_ONE_95_12 : EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_ONE_90_12) : EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_ONE_34;
            score = EXCELLENT + (excellent - oneThousandMeterRun) / excelBase;
        } else if (oneThousandMeterRun <= good) {
            Double goodBase = isOneTwo ? ((oneThousandMeterRun > GOOD_BOY_ONE_THOUSAND_METER_RUN_80_12) ? GOOD_BOY_ONE_THOUSAND_METER_RUN_ONE_85_12 : GOOD_BOY_ONE_THOUSAND_METER_RUN_ONE_80_12) : ((oneThousandMeterRun > GOOD_BOY_ONE_THOUSAND_METER_RUN_80_34) ? GOOD_BOY_ONE_THOUSAND_METER_RUN_ONE_85_34 : GOOD_BOY_ONE_THOUSAND_METER_RUN_ONE_80_34);
            score = GOOD + (good - oneThousandMeterRun) / goodBase;
        } else if (oneThousandMeterRun <= pass) {
            Double passBase = isOneTwo ? PASS_BOY_ONE_THOUSAND_METER_RUN_ONE_12 : PASS_BOY_ONE_THOUSAND_METER_RUN_ONE_34;
            score = PASS + (pass - oneThousandMeterRun) / passBase;
        } else {
            Double failBase = isOneTwo ? FAIL_BOY_ONE_THOUSAND_METER_RUN_ONE_12 : FAIL_BOY_ONE_THOUSAND_METER_RUN_ONE_34;
            score = FAIL + (fail - oneThousandMeterRun) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算引体向上成绩
     *
     * @param : pullUps 引体向上成绩
     * @param : isMale 是否为男生
     * @param : isOneTwo 是否为大一/大二
     * @return : 成绩
     * @auther: 唐文涛
     */
    //计算引体向上成绩
    public static double calculatePullUpsScore(Integer pullUps, boolean isOneTwo) {
        Integer full = isOneTwo ? FULL_BOY_PULL_UPS_12 : FULL_BOY_PULL_UPS_34;
        Integer excellent = isOneTwo ? EXCELLENT_BOY_PULL_UPS_12 : EXCELLENT_BOY_PULL_UPS_34;
        Integer good = isOneTwo ? GOOD_BOY_PULL_UPS_12 : GOOD_BOY_PULL_UPS_34;
        Integer pass = isOneTwo ? PASS_BOY_PULL_UPS_12 : PASS_BOY_PULL_UPS_34;
        Integer fail = isOneTwo ? FAIL_BOY_PULL_UPS_12 : FAIL_BOY_PULL_UPS_34;

        // 判断成绩等级并计算分数
        double score;
        if (pullUps >= full) {
            score = FULL + min((pullUps - full) / ONE, 10);
        } else if (pullUps >= excellent) {
            Double excelBase = isOneTwo ? EXCELLENT_BOY_PULL_UPS_ONE_12 : EXCELLENT_BOY_PULL_UPS_ONE_34;
            score = EXCELLENT + (pullUps - excellent) / excelBase;
        } else if (pullUps >= good) {
            Double goodBase = isOneTwo ? GOOD_BOY_PULL_UPS_ONE_12 : GOOD_BOY_PULL_UPS_ONE_34;

            score = GOOD + (pullUps - good) / goodBase;
        } else if (pullUps >= pass) {
            Double passBase = isOneTwo ? PASS_BOY_PULL_UPS_ONE_12 : PASS_BOY_PULL_UPS_ONE_34;

            score = PASS + (pullUps - pass) / passBase;
        } else {
            Double failBase = isOneTwo ? FAIL_BOY_PULL_UPS_ONE_12 : FAIL_BOY_PULL_UPS_ONE_34;
            score = FAIL + (pullUps - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算一分钟仰卧起坐成绩
     *
     * @param oneMinuteSitUps 一分钟仰卧起坐成绩
     * @param isOneTwo        是否为大一/大二
     * @return 成绩
     * @author: 唐文涛
     */
    // 计算一分钟仰卧起坐成绩
    public static double calculateOneMinuteSitUpsScore(Integer oneMinuteSitUps, boolean isOneTwo) {


        Integer full = isOneTwo ? FULL_GIRL_ONE_MINUTE_SIT_UPS_12 : FULL_GIRL_ONE_MINUTE_SIT_UPS_34;
        Integer excellent = isOneTwo ? EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_12 : EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_34;
        Integer good = isOneTwo ? GOOD_GIRL_ONE_MINUTE_SIT_UPS_12 : GOOD_GIRL_ONE_MINUTE_SIT_UPS_34;
        Integer pass = isOneTwo ? PASS_GIRL_ONE_MINUTE_SIT_UPS_12 : PASS_GIRL_ONE_MINUTE_SIT_UPS_34;
        Integer fail = isOneTwo ? FAIL_GIRL_ONE_MINUTE_SIT_UPS_12 : FAIL_GIRL_ONE_MINUTE_SIT_UPS_34;


        // 判断成绩等级并计算分数
        double score;
        if (oneMinuteSitUps >= full) {
            if (oneMinuteSitUps - full > 6) {
                score = FULL + min((oneMinuteSitUps - full) - THREE, 10);
            } else {
                score = FULL + min((oneMinuteSitUps - full) / TWO, 10);
            }
        } else if (oneMinuteSitUps >= excellent) {
            Double excelBase = isOneTwo ? EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = EXCELLENT + (oneMinuteSitUps - excellent) / excelBase;
        } else if (oneMinuteSitUps >= good) {
            Double goodBase = isOneTwo ? GOOD_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : GOOD_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = GOOD + (oneMinuteSitUps - good) / goodBase;
        } else if (oneMinuteSitUps >= pass) {
            Double passBase = isOneTwo ? PASS_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : PASS_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = PASS + (oneMinuteSitUps - pass) / passBase;
        } else {
            Double failBase = isOneTwo ? FAIL_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : FAIL_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = FAIL + (oneMinuteSitUps - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算800米跑成绩
     *
     * @param eightHundredMeterRun 800米跑成绩     是否为男生
     * @param isOneTwo             是否为大一/大二
     * @return 成绩
     */
    // 计算八百米跑步成绩
    public static double calculateEightHundredMeterRunScore(Integer eightHundredMeterRun, boolean isOneTwo) {


        Integer full = isOneTwo ? FULL_GIRL_EIGHT_HUNDRED_METER_RUN_12 : FULL_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer excellent = isOneTwo ? EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_12 : EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer good = isOneTwo ? GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_12 : GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer pass = isOneTwo ? PASS_GIRL_EIGHT_HUNDRED_METER_RUN_12 : PASS_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer fail = isOneTwo ? FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_12 : FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_34;


        // 判断成绩等级并计算分数
        double score;
        if (eightHundredMeterRun <= full) {
            score = FULL + min((full - eightHundredMeterRun) / FIVE, 10);
        } else if (eightHundredMeterRun <= excellent) {
            Double excelBase = isOneTwo ? EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 : EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = EXCELLENT + (excellent - eightHundredMeterRun) / excelBase;
        } else if (eightHundredMeterRun <= good) {
            Double goodBase = isOneTwo ? GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 : GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = GOOD + (good - eightHundredMeterRun) / goodBase;
        } else if (eightHundredMeterRun <= pass) {
            Double passBase = isOneTwo ? PASS_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 : PASS_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = PASS + (pass - eightHundredMeterRun) / passBase;
        } else {
            Double failBase = isOneTwo ? FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 : FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = FAIL + (fail - eightHundredMeterRun) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算坐位体前屈成绩
     *
     * @param sitAndReach 坐位体前屈成绩
     * @param isMale      是否为男生
     * @param isOneTwo    是否为大一/大二
     * @author: 唐文涛
     */
    //// 计算坐位体前屈成绩
    public static double calculateSitAndReachScore(Double sitAndReach, boolean isMale, boolean isOneTwo) {

        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_SIT_AND_REACH_12 : EXCELLENT_BOY_SIT_AND_REACH_34) : (isOneTwo ? EXCELLENT_GIRL_SIT_AND_REACH_12 : sitAndReach > EXCELLENT_GIRL_SIT_AND_REACH_90_34 ? EXCELLENT_GIRL_SIT_AND_REACH_95_34 : EXCELLENT_GIRL_SIT_AND_REACH_90_34);
        Double good = isMale ? (isOneTwo ? GOOD_BOY_SIT_AND_REACH_12 : GOOD_BOY_SIT_AND_REACH_34) : (isOneTwo ? GOOD_GIRL_SIT_AND_REACH_12 : (sitAndReach > GOOD_GIRL_SIT_AND_REACH_80_34 ? GOOD_GIRL_SIT_AND_REACH_85_34 : GOOD_GIRL_SIT_AND_REACH_80_34));
        Double pass = isMale ? (isOneTwo ? PASS_BOY_SIT_AND_REACH_12 : PASS_BOY_SIT_AND_REACH_34) : (isOneTwo ? PASS_GIRL_SIT_AND_REACH_12 : PASS_GIRL_SIT_AND_REACH_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_SIT_AND_REACH_12 : FAIL_BOY_SIT_AND_REACH_34) : (isOneTwo ? FAIL_GIRL_SIT_AND_REACH_12 : FAIL_GIRL_SIT_AND_REACH_34);


        // 判断成绩等级并计算分数
        double score;
        if (sitAndReach >= excellent) {
            Double excelBase = isMale ? (isOneTwo ? EXCELLENT_BOY_SIT_AND_REACH_ONE_12 : EXCELLENT_BOY_SIT_AND_REACH_ONE_34) : (isOneTwo ? EXCELLENT_GIRL_SIT_AND_REACH_ONE_12 : (sitAndReach > EXCELLENT_GIRL_SIT_AND_REACH_90_34 ? EXCELLENT_GIRL_SIT_AND_REACH_ONE_90_34 : EXCELLENT_GIRL_SIT_AND_REACH_ONE_95_34));
            score = EXCELLENT + (sitAndReach - excellent) / excelBase;
        } else if (sitAndReach >= good) {
            Double goodBase = isMale ? (isOneTwo ? GOOD_BOY_SIT_AND_REACH_ONE_12 : GOOD_BOY_SIT_AND_REACH_ONE_34) : (isOneTwo ? GOOD_GIRL_SIT_AND_REACH_ONE_12 : (sitAndReach > GOOD_GIRL_SIT_AND_REACH_80_34 ? GOOD_GIRL_SIT_AND_REACH_ONE_80_34 : GOOD_GIRL_SIT_AND_REACH_ONE_85_34));
            score = GOOD + (sitAndReach - good) / goodBase;
        } else if (sitAndReach >= pass) {
            Double passBase = isMale ? (isOneTwo ? PASS_BOY_SIT_AND_REACH_ONE_12 : PASS_BOY_SIT_AND_REACH_ONE_34) : (isOneTwo ? PASS_GIRL_SIT_AND_REACH_ONE_12 : PASS_GIRL_SIT_AND_REACH_ONE_34);
            score = PASS + (sitAndReach - pass) / passBase;
        } else {
            Double failBase = isMale ? (isOneTwo ? FAIL_BOY_SIT_AND_REACH_ONE_12 : FAIL_BOY_SIT_AND_REACH_ONE_34) : (isOneTwo ? FAIL_GIRL_SIT_AND_REACH_ONE_12 : FAIL_GIRL_SIT_AND_REACH_ONE_34);
            score = FAIL + (sitAndReach - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /***
     * 计算立定跳远成绩
     * @auther: 唐文涛
     * @param standingLongJump  立定跳远成绩
     * @param isMale 是否为男生
     * @param isOneTwo 是否为大一/大二
     * @return 成绩
     */
    //计算立定跳远成绩
    public static double calculateStandingLongJumpScore(Double standingLongJump, boolean isMale, boolean isOneTwo) {
        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_STANDING_LONG_JUMP_12 : EXCELLENT_BOY_STANDING_LONG_JUMP_34) : (isOneTwo ? EXCELLENT_GIRL_STANDING_LONG_JUMP_12 : EXCELLENT_GIRL_STANDING_LONG_JUMP_34);

        Double good = isMale ? (isOneTwo ? (standingLongJump > GOOD_BOY_STANDING_LONG_JUMP_80_12 ? GOOD_BOY_STANDING_LONG_JUMP_85_12 : GOOD_BOY_STANDING_LONG_JUMP_80_12) : (standingLongJump > GOOD_BOY_STANDING_LONG_JUMP_80_34 ? GOOD_BOY_STANDING_LONG_JUMP_85_34 : GOOD_BOY_STANDING_LONG_JUMP_80_34))

                : (isOneTwo ? GOOD_GIRL_STANDING_LONG_JUMP_12 : GOOD_GIRL_STANDING_LONG_JUMP_34);

        Double pass = isMale ? (isOneTwo ? PASS_BOY_STANDING_LONG_JUMP_12 : PASS_BOY_STANDING_LONG_JUMP_34) : (isOneTwo ? PASS_GIRL_STANDING_LONG_JUMP_12 : PASS_GIRL_STANDING_LONG_JUMP_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_STANDING_LONG_JUMP_12 : FAIL_BOY_STANDING_LONG_JUMP_34) : (isOneTwo ? FAIL_GIRL_STANDING_LONG_JUMP_12 : FAIL_GIRL_STANDING_LONG_JUMP_34);


        // 判断成绩等级并计算分数
        double score;
        if (standingLongJump >= excellent) {
            Double excelBase = isMale ? (isOneTwo ? EXCELLENT_BOY_STANDING_LONG_JUMP_ONE_12 : EXCELLENT_BOY_STANDING_LONG_JUMP_ONE_34) : (isOneTwo ? EXCELLENT_GIRL_STANDING_LONG_JUMP_ONE_12 : EXCELLENT_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = EXCELLENT + (standingLongJump - excellent) / excelBase;
        } else if (standingLongJump >= good) {
            Double goodBase = isMale ? (isOneTwo ? (standingLongJump > GOOD_BOY_STANDING_LONG_JUMP_80_12 ? GOOD_BOY_STANDING_LONG_JUMP_ONE_85_12 : GOOD_BOY_STANDING_LONG_JUMP_ONE_80_12) : (standingLongJump > GOOD_BOY_STANDING_LONG_JUMP_80_34 ? GOOD_BOY_STANDING_LONG_JUMP_ONE_85_34 : GOOD_BOY_STANDING_LONG_JUMP_ONE_80_34))
                    : (isOneTwo ? GOOD_GIRL_STANDING_LONG_JUMP_ONE_12 : GOOD_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = GOOD + (standingLongJump - good) / goodBase;
        } else if (standingLongJump >= pass) {
            Double passBase = isMale ? (isOneTwo ? PASS_BOY_STANDING_LONG_JUMP_ONE_12 : PASS_BOY_STANDING_LONG_JUMP_ONE_34) : (isOneTwo ? PASS_GIRL_STANDING_LONG_JUMP_ONE_12 : PASS_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = PASS + (standingLongJump - pass) / passBase;
        } else {
            Double failBase = isMale ? (isOneTwo ? FAIL_BOY_STANDING_LONG_JUMP_ONE_12 : FAIL_BOY_STANDING_LONG_JUMP_ONE_34) : (isOneTwo ? FAIL_GIRL_STANDING_LONG_JUMP_ONE_12 : FAIL_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = FAIL + (standingLongJump - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算50米跑成绩
     *
     * @param fiftyMeterRun 50米跑成绩
     * @param isMale        是否为男生
     * @param isOneTwo      是否为大一/大二
     * @return 成绩
     * @author: 唐文涛
     */

    public static double calculateFiftyMeterRunScore(Double fiftyMeterRun, boolean isMale, boolean isOneTwo) {
        // 定义基准时间和基准分
        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_FIFTY_METER_RUN_12 : EXCELLENT_BOY_FIFTY_METER_RUN_34) : (isOneTwo ? EXCELLENT_GIRL_FIFTY_METER_RUN_12 : EXCELLENT_GIRL_FIFTY_METER_RUN_34);
        Double good = isMale ? (isOneTwo ? GOOD_BOY_FIFTY_METER_RUN_12 : GOOD_BOY_FIFTY_METER_RUN_34) : (isOneTwo ? GOOD_GIRL_FIFTY_METER_RUN_12 : GOOD_GIRL_FIFTY_METER_RUN_34);
        Double pass = isMale ? (isOneTwo ? PASS_BOY_FIFTY_METER_RUN_12 : PASS_BOY_FIFTY_METER_RUN_34) : (isOneTwo ? PASS_GIRL_FIFTY_METER_RUN_12 : PASS_GIRL_FIFTY_METER_RUN_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_FIFTY_METER_RUN_12 : FAIL_BOY_FIFTY_METER_RUN_34) : (isOneTwo ? FAIL_GIRL_FIFTY_METER_RUN_12 : FAIL_GIRL_FIFTY_METER_RUN_34);

        // 判断成绩等级并计算分数
        double score;
        if (fiftyMeterRun <= excellent) {
            Double excelBase = isMale ? (isOneTwo ? EXCELLENT_BOY_FIFTY_METER_RUN_ONE_12 : EXCELLENT_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ? EXCELLENT_GIRL_FIFTY_METER_RUN_ONE_12 : EXCELLENT_GIRL_FIFTY_METER_RUN_ONE_34);
            score = EXCELLENT + Math.round((excellent - fiftyMeterRun) / excelBase);
        } else if (fiftyMeterRun <= good) {
            Double goodBase = isMale ? (isOneTwo ? GOOD_BOY_FIFTY_METER_RUN_ONE_12 : GOOD_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ? GOOD_GIRL_FIFTY_METER_RUN_ONE_12 : GOOD_GIRL_FIFTY_METER_RUN_ONE_34);
            score = GOOD + Math.round((good - fiftyMeterRun) / goodBase);
        } else if (fiftyMeterRun <= pass) {
            Double passBase = isMale ? (isOneTwo ? PASS_BOY_FIFTY_METER_RUN_ONE_12 : PASS_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ? PASS_GIRL_FIFTY_METER_RUN_ONE_12 : PASS_GIRL_FIFTY_METER_RUN_ONE_34);
            score = PASS + Math.round((pass - fiftyMeterRun) / passBase);
        } else {
            Double failBase = isMale ? (isOneTwo ? FAIL_BOY_FIFTY_METER_RUN_ONE_12 : FAIL_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ? FAIL_GIRL_FIFTY_METER_RUN_ONE_12 : FAIL_GIRL_FIFTY_METER_RUN_ONE_34);
            score = FAIL + Math.round((fail - fiftyMeterRun) / failBase);;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算肺活量成绩
     *
     * @param lungCapacity 肺活量
     * @param isMale       是否为男生
     * @param isOneTwo     是否为大一/大二
     * @return 成绩
     * @author 唐文涛
     */
    public static double calculateLungCapacityScore(Double lungCapacity, boolean isMale, boolean isOneTwo) {
        // 确定基准值和分数常量
        Integer excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_LUNG_CAPACITY_12 : EXCELLENT_BOY_LUNG_CAPACITY_34) : (isOneTwo ? EXCELLENT_GIRL_LUNG_CAPACITY_12 : EXCELLENT_GIRL_LUNG_CAPACITY_34);
        Integer good = isMale ? (isOneTwo ? GOOD_BOY_LUNG_CAPACITY_12 : GOOD_BOY_LUNG_CAPACITY_34) : (isOneTwo ? GOOD_GIRL_LUNG_CAPACITY_12 : GOOD_GIRL_LUNG_CAPACITY_34);
        Integer pass = isMale ? (isOneTwo ? PASS_BOY_LUNG_CAPACITY_12 : PASS_BOY_LUNG_CAPACITY_34) : (isOneTwo ? PASS_GIRL_LUNG_CAPACITY_12 : PASS_GIRL_LUNG_CAPACITY_34);
        Integer fail = isMale ? (isOneTwo ? FAIL_BOY_LUNG_CAPACITY_12 : FAIL_BOY_LUNG_CAPACITY_34) : (isOneTwo ? FAIL_GIRL_LUNG_CAPACITY_12 : FAIL_GIRL_LUNG_CAPACITY_34);
        // 计算成绩
        double score;
        if (lungCapacity >= excellent) {
            Integer excelBase = isMale ? (isOneTwo ? EXCELLENT_BOY_LUNG_CAPACITY_ONE_12 : EXCELLENT_BOY_LUNG_CAPACITY_ONE_34) : (isOneTwo ? EXCELLENT_GIRL_LUNG_CAPACITY_ONE_12 : EXCELLENT_GIRL_LUNG_CAPACITY_ONE_34);
            score = EXCELLENT + (lungCapacity - excellent) / excelBase;
        } else if (lungCapacity >= good) {
            Integer goodBase = isMale ? (isOneTwo ? GOOD_BOY_LUNG_CAPACITY_ONE_12 : GOOD_BOY_LUNG_CAPACITY_ONE_34) : (isOneTwo ? GOOD_GIRL_LUNG_CAPACITY_ONE_12 : GOOD_GIRL_LUNG_CAPACITY_ONE_34);
            score = GOOD + (lungCapacity - good) / goodBase;
        } else if (lungCapacity >= pass) {
            Integer passBase = isMale ? (isOneTwo ? PASS_BOY_LUNG_CAPACITY_ONE_12 : PASS_BOY_LUNG_CAPACITY_ONE_34) : (isOneTwo ? PASS_GIRL_LUNG_CAPACITY_ONE_12 : PASS_GIRL_LUNG_CAPACITY_ONE_34);
            score = PASS + (lungCapacity - pass) / passBase;
        } else {
            Integer failBase = isMale ? (isOneTwo ? FAIL_BOY_LUNG_CAPACITY_ONE_12 : FAIL_BOY_LUNG_CAPACITY_ONE_34) : (isOneTwo ? FAIL_GIRL_LUNG_CAPACITY_ONE_12 : FAIL_GIRL_LUNG_CAPACITY_ONE_34);
            score = FAIL + (lungCapacity - fail) / failBase;
        }
        return conversion(score);
    }
}